package 反射.jdk动态代理.v1;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class DynamicProxyHandler implements InvocationHandler {

	// 代理类中的真实对象
	private Object obj;

	// 构造函数，给真实对象赋值
	public DynamicProxyHandler(Object obj) {
		this.obj = obj;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println(method.getName());

		System.out.println("before invoke:" + method.getName());

		Object invoke = method.invoke(obj, args);

		System.out.println("after invoke:" + method.getName());

		return invoke;
	}

}
